# encoding: utf-8

from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from wsgi import create_app
from exts import db
import random
from apps.front.models import Company

app = create_app()

manager = Manager(app)

Migrate(app, db)
manager.add_command('db', MigrateCommand)


@manager.command
def init_db():
    company_type = ['小', '中', '大']
    for i in range(100):
        db.session.add(Company(name='某某公司'+str(i), scale=random.choice(company_type)))
    db.session.commit()


if __name__ == '__main__':
    manager.run()
